home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / LISTMANA / __TESTER / TESTERWI.C < prev    next >
Text File  |  1989-06-25  |  4KB  |  214 lines

  1. /****                                                                    */
  2. /****    Code Testing System version 1.0 (beta)                            */
  3. /****                                                                    */
  4. /****    All portions of this source code are the property of Jack        */
  5. /****    Herrington.  I, Jack Herrington, give you permission to use        */
  6. /****    use or alter the code in any way that pleases you.  You must    */
  7. /****    however return by whatever means avaliable any improvements        */
  8. /****    you believe significant to Jack Herrington, accepting that        */
  9. /****    these improvements might be contained in later releases of        */
  10. /****    the code. I also grant you permission to remove this header        */
  11. /****    from any file you are WORKING on, as long as you put it back    */
  12. /****    when you're stopped WORKING on it.                                */
  13. /****                                                                    */
  14. /****    Jack Herrington: University Of Miami, Biomedical Computing        */
  15. /****                     1600 N.W. 10th Ave. (R-53)                        */
  16. /****                     (305) 547-6538                                    */
  17. /****                                                                    */
  18.  
  19. /****/
  20. /**** Window handling routines */
  21. /****/
  22.  
  23. #include "Tester.h"
  24.  
  25. /****/
  26. /**** Create a new dialog */
  27. /****/
  28.  
  29. int TesterDialogNew(resID,handler)
  30. int resID;
  31. int handler;
  32. {
  33.     int y,win;
  34.  
  35.         /**** Find open window slot */
  36.  
  37.     win=(-1);
  38.     for(y=0;y<MAX_WINDOWS;y++)
  39.     {
  40.         if(Windows[y].window == 0L)win=y;
  41.     }
  42.     if(win==(-1))return (-1);
  43.  
  44.         /**** Get the new dialog */
  45.  
  46.     Windows[win].window = GetNewDialog(resID,Windows[win].wStorage,-1L);
  47.     if ( Windows[win].window == 0L ) return (-1);
  48.     Windows[win].handler = handler;
  49.     Windows[win].idle = Handlers[handler].idle;
  50.  
  51.         /**** Setup the current */
  52.  
  53.     CurWindow = win;
  54.  
  55.         /**** Return the address */
  56.  
  57.     return win;
  58. }
  59.  
  60. /****/
  61. /**** Find the window */
  62. /****/
  63.  
  64. int TesterFindProgWindow(window)
  65. WindowPtr window;
  66. {
  67.     int win;
  68.  
  69.     for(win=0;win<MAX_WINDOWS;win++)
  70.         if(Windows[win].window == window)return win;
  71.     return (-1);
  72. }
  73.  
  74. /****/
  75. /**** Allocate window data */
  76. /****/
  77.  
  78. void TesterAllocateWindowData(size)
  79. long size;
  80. {
  81.     Windows[CurWindow].data = NewHandle((Size)size);
  82. }
  83.  
  84. /****/
  85. /**** Lock the current windows information */
  86. /****/
  87.  
  88. void TesterLockWindowInfo()
  89. {
  90.     HLock(Windows[CurWindow].data);
  91. }
  92.  
  93. /****/
  94. /**** Lock the current windows information from a window pointer */
  95. /****/
  96.  
  97. void TesterLockWindowInfoWindow(window)
  98. WindowPtr window;
  99. {
  100.     int winNum;
  101.  
  102.     winNum = TesterFindProgWindow(window);
  103.     HLock(Windows[winNum].data);
  104. }
  105.  
  106. /****/
  107. /**** Lock the current windows information from a window pointer */
  108. /****/
  109.  
  110. void TesterUnLockWindowInfoWindow(window)
  111. WindowPtr window;
  112. {
  113.     int winNum;
  114.  
  115.     winNum = TesterFindProgWindow(window);
  116.     HUnlock(Windows[winNum].data);
  117. }
  118.  
  119. /****/
  120. /**** Lock the a windows information */
  121. /****/
  122.  
  123. void TesterLockWindowInfoNum(win)
  124. int win;
  125. {
  126.     HLock(Windows[win].data);
  127. }
  128.  
  129. /****/
  130. /**** UnLock the current windows information */
  131. /****/
  132.  
  133. void TesterUnLockWindowInfo()
  134. {
  135.     int win;
  136.  
  137.     for(win=0;win<MAX_WINDOWS;win++)
  138.         if(Windows[win].data!=0L)HUnlock(Windows[win].data);
  139. }
  140.  
  141. /****/
  142. /**** UnLock the a windows information */
  143. /****/
  144.  
  145. void TesterUnLockWindowInfoNum(win)
  146. int win;
  147. {
  148.     HUnlock(Windows[win].data);
  149. }
  150.  
  151. /****/
  152. /**** Get the window information attached to the current window */
  153. /****/
  154.  
  155. unsigned char *TesterGetWindowInfo()
  156. {
  157.     return (unsigned char *)*Windows[CurWindow].data;
  158. }
  159.  
  160. /****/
  161. /**** Get the window information with the identity of the window */
  162. /****/
  163.  
  164. unsigned char *TesterGetWindowInfoIndirect(window)
  165. WindowPtr window;
  166. {
  167.     int win;
  168.  
  169.     if ( ( win = TesterFindProgWindow(window) ) == (-1) ) return 0L;
  170.  
  171.     return (unsigned char *)*Windows[win].data;
  172. }
  173.  
  174. /****/
  175. /**** Close a window */
  176. /****/
  177.  
  178. void TesterKillWindow(win)
  179. int win;
  180. {
  181.     int ent;
  182.  
  183.     DisposDialog(Windows[win].window);
  184.     Windows[win].window = 0L;
  185.     Windows[win].wStorage = 0L;
  186.     DisposHandle(Windows[win].data);
  187.     Windows[win].data = 0L;
  188.     Windows[win].handler = 0;
  189.  
  190.     CurWindow=(-1);
  191. }
  192.  
  193. /****/
  194. /**** If there is a window bring it to the front and report */
  195. /****/
  196.  
  197. int TesterOnlyOneHandler(handler)
  198. int handler;
  199. {
  200.     int win,wnum;
  201.  
  202.     win=(-1);
  203.     for(wnum=0;wnum<MAX_WINDOWS;wnum++)
  204.     {
  205.         if(Windows[wnum].handler == handler)win=wnum;
  206.     }
  207.  
  208.     if(win!=(-1))
  209.     {
  210.         SelectWindow(Windows[win].window);
  211.         return 1;
  212.     }
  213.     return 0;
  214. }